package com.pyb.java.network.interceptor;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

/**
 * @Params :拦截请求获取请求参数进行统一加密处理
 * @Author :zhaohuiming
 * @Date :2019/12/10
 */
public class EncryptionInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {

        //获取请求request
        Request oldRequest = chain.request();

        RequestBody oldRequestBady = oldRequest.body();

        MediaType mediaType = oldRequestBady.contentType();

        Request.Builder builder = oldRequest.newBuilder();

        builder.method(oldRequest.method(),oldRequest.body());

//        oldRequestBady.writeTo(new StringBuffer());

        return chain.proceed(builder.build());
    }
}
